package io.renren.modules.app.controller.user;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import io.renren.modules.app.entity.user.UserExperienceEntity;
import io.renren.modules.app.service.user.UserExperienceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;


/**
 *
 *
 * @author lym
 * @email 928185446qq.com
 * @date 2023-12-21 17:02:58
 */
@RestController
@RequestMapping("userExperience")
public class UserExperienceController {
    @Autowired
    private UserExperienceService UserExperienceService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = UserExperienceService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		UserExperienceEntity UserExperience = UserExperienceService.getById(id);

        return R.ok().put("UserExperience", UserExperience);
    }
    /**
     * 通过resumeId查询
     */
    @RequestMapping("/infoByResumeId/{resumeId}")
    public R infoByResumeId(@PathVariable("resumeId") Integer resumeId){
        UserExperienceEntity UserExperience = UserExperienceService.getByResumeId(resumeId);

        return R.ok().put("UserExperience", UserExperience);
    }
    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody UserExperienceEntity UserExperience){
        UserExperience.setAddtime(new Date());
        UserExperience.setDeletestatus(false);
		UserExperienceService.saveOrUpdate(UserExperience);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserExperienceEntity UserExperience){
		UserExperienceService.updateById(UserExperience);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		UserExperienceService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
